package junior.DynamicProgramming动态规划;

public class 钢条切割 {
    public static int[][] pi = {{1,2,3,4,5,6,7,8,9,10},
                                {1,5,8,9,10,17,17,20,24,30}};
    public static int[][] dp1 = new int[2][10]; // 长度，最优子结构

    public static void main(String[] args) {
        int[][] dp = new int[2][10]; // 长度，最优子结构
        int len = 10;
        for (int i = 0; i < len; i++) {
            for (int j = 1; j <= i; j++) { // j: 分割位置
                dp[1][i] = Math.max(dp[1][j-1] + dp[1][i-j], dp[1][i]);
            }
            dp[1][i] = Math.max(dp[1][i], pi[1][i]);
        }
        for (int i = 0; i < len; i++) {
            System.out.println("dp[1][" + i + "] = " + dp[1][i]);
        }
    }
}
